/**
 * Dictionary Class
 * Responsibilities:
 * - Reads and process Foldoc Raw File
 * - Answers to the question if the given string is valid or not
 * @author kkopiec
 *
 */
import java.util.*;
import java.io.*;
public class Dictionary {
	protected List<String> dict; // Main directory list of terms
	/**
	 * default constructor
	 * variable initialisation
	 */
	public Dictionary(){
		dict = new ArrayList<String>();
		readDict();
	}
	/**
	 * Reads Contents of preprocessed dictionary file
	 * into internal dictionary list
	 * called internally from constructor
	 */
	protected void readDict(){
		try {
			File dictFile = new File("foldoct.dict");
			FileReader frd = new FileReader(dictFile);
			BufferedReader brd = new BufferedReader(frd);
			String line = null;
			while ((line = brd.readLine()) != null) {
				dict.add(line);
			}
			brd.close();
		} catch (Exception ex) {
			System.out
					.println("ERR: Something went terribly wrong while reading file !!");
			ex.printStackTrace();
		}
	}
	public boolean check ( String token ){
		for (String tmp: dict){
			if (tmp.equalsIgnoreCase(token)) return true;
		}
		return false;
	}
	
}
